package com.zkx.mvp.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;

import com.zkx.mvp.R;
import com.zkx.mvp.utils.AppManager;

/**
 * Author：zhangkx on 2017/6/16 16:59
 * Email：zkx9025@163.com
 * activity的基类
 */

public  class BaseActivity1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_main_layout);

        AppManager.getAppManager().addActivity(this);
    }
    //添加fragment
    public void addFrag(Fragment fragment, int resId) {
        getSupportFragmentManager().beginTransaction().add(resId, fragment)
                .commit();
    }
    //替换fragment
    public void replaceFrag(Fragment fragment, int resId) {
        getSupportFragmentManager().beginTransaction().replace(resId, fragment)
                .commit();
    }
    @Override
    public void startActivity(Intent intent) {
        super.startActivity(intent);
        overridePendingTransition(R.animator.base_slide_right_in,
                R.animator.base_slide_remain);
    }
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(0, R.animator.base_slide_right_out);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }
}
